﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Omnia.DataModels;
using Omnia.Enums;

namespace Omnia.ViewModels
{
    public class StatisticsViewModel:MainViewModel
    {
        #region Method

        public IEnumerable<TransactionStatisticInfo> GetStatisticGroup(IEnumerable<TransactionInfo> trans, StatisticKindValue kind, int max)
        {
            if (kind == StatisticKindValue.Daily)
            {
                for (var i = 1; i <= max; i++)
                {
                    double sum = trans.Where(t => t.Day == i).Sum(t => t.Amount);
                    yield return new TransactionStatisticInfo(sum == null ? 0 : sum, i);
                }
            }
            else
            {
                for (var i = 1; i <= max; i++)
                {
                    double sum = trans.Where(t => t.Month == i).Sum(t => t.Amount);
                    yield return new TransactionStatisticInfo(sum == null ? 0 : sum, i);
                }
            }
        }
        #endregion
    }
}
